<template>
  <div class="app-container">
    <template>
      <div class="right-detail">
        <div class="cbox">
          <el-form
            class="form"
            :model="queryParam"
            ref="queryParam"
            :rules="rules"
            label-width="9rem"
            size="mini"
          >
            <el-row :gutter="12" class="row">
              <el-col :span="6">
                <el-form-item size="mini" label="标的编号：" prop="bidCode" label-width="85px">
                  <el-input clearable v-model="queryParam.bidCode" size="mini" style="width: 180px"></el-input>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="5">
                <el-form-item size="mini" label="竞价状态：" prop="biddingStatus" label-width="100px">
                <el-select clearable v-model="queryParam.biddingStatus" style="width: 100%" placeholder="请选择">
                  <el-option v-for="(item, index) in statusList" :key="index" :value="item.code" :label="item.name">
                  </el-option>
                </el-select>
              </el-form-item>
              </el-col>-->
              <el-col :span="2">
                <el-form-item label-width="10px">
                  <el-button @click="searchType" type="primary">查询</el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
        <split-pane split="horizontal" v-on:resize="resize" :default-percent="55" :max-percent="80">
          <!-- 上半部分 -->
          <template slot="paneL">
            <div class="top-type" ref="topType">
              <div class="btn-area" ref="detlArea">
                <buttonName @clickEvent="clickEventDom"></buttonName>
                <!-- <el-button plain size="mini" type="primary" v-if="isAuth('biddingButton')" @click="biddingButton">竞价</el-button>
                <el-button plain size="mini" type="primary" v-if="isAuth('delbiddingButton')" @click="delbiddingButton">取消竞价</el-button>
                <el-button plain size='mini' type="primary" v-if="isAuth('biddingOutExcel')" @click='outExcel'>导出</el-button>-->
              </div>
              <!-- 状态（E-启用 N-未启用 D-停用） -->
              <el-table
                :data="TypeList"
                :height="typeHeight"
                highlight-current-row
                class="demand"
                @row-click="getCurrentTypeRow"
                border
                :header-cell-style="{ textAlign: 'center' }"
                :cell-style="{}"
              >
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  type="index"
                  label="序号"
                  align="center"
                  width="60"
                >
                  <template slot-scope="scope">
                    <span>{{ (Pagination.currentPage - 1) * Pagination.pageSize + scope.$index + 1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="bidCode"
                  align="center"
                  width="120"
                  label="标的编号"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="bidName"
                  align="center"
                  width="220"
                  label="标的名称"
                ></el-table-column>
                <el-table-column
                  align="center"
                  label="标的状态"
                  prop="bidStatus"
                  width="105"
                  show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="bidType"
                  align="center"
                  label="标的类型"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="bidAmount"
                  width="120"
                  align="center"
                  label="运输总量（吨）"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="bidSignupStart"
                  width="160"
                  align="center"
                  label="竞价报名开始时间"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="bidSignupEnd"
                  width="160"
                  align="center"
                  label="竞价报名结束时间"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="bidBiddingStart"
                  width="160"
                  align="center"
                  label="竞价开始时间"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="bidBiddingEnd"
                  width="160"
                  align="center"
                  label="竞价结束时间"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="bidOffer"
                  width="150"
                  align="center"
                  label="单价竞价范围（元/吨）"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="bidQuotations"
                  align="left"
                  label="竞价方式"
                ></el-table-column>
                <!-- <el-table-column size="mini" show-overflow-tooltip prop="bidAppointMan" align="left" label="供应商指定人"></el-table-column> -->
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  width="120"
                  prop="dptName"
                  label="标的来源"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  header-align="left"
                  align="left"
                  prop="bidRemark"
                  label="备注"
                ></el-table-column>
              </el-table>
              <div>
                <el-pagination
                  class="pagination"
                  small
                  background
                  ref="pagination"
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="Pagination.currentPage"
                  :page-sizes="Pagination.pageSizeList"
                  :page-size="Pagination.pageSize"
                  :layout="Pagination.layout"
                  :total="Pagination.total"
                ></el-pagination>
              </div>
            </div>
          </template>

          <!-- 下半部分 -->
          <template slot="paneR">
            <div class="codeNumberCode" style="background-color: #fff;">需求信息</div>
            <div class="bottom-code" ref="bottomCode" style="background-color: #fff;">
              <!-- <div class="btn-area" ref="detlArea">
                <el-button plain size="mini" type="primary" v-if="isAuth('biddingButton')" @click="biddingButton">竞价</el-button>
                <el-button plain size="mini" type="primary" v-if="isAuth('delbiddingButton')" @click="delbiddingButton">取消竞价</el-button>
                <el-button plain size="mini" type="warning" @click="queryBiddingButton">查看竞价信息</el-button>
              </div>-->
              <el-table
                :height="detlHeight"
                :data="currentCodeList"
                highlight-current-row
                @row-click="getCurrentCodeRow"
                border
                :header-cell-style="{
                  textAlign: 'center'
                }"
                :cell-style="{}"
              >
                <el-table-column
                  type="index"
                  show-overflow-tooltip
                  align="center"
                  width="60%"
                  label="序号"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  width="120"
                  align="left"
                  prop="demandCode"
                  label="需求编号"
                ></el-table-column>
                <el-table-column
                  align="center"
                  label="竞价状态"
                  prop="biddingStatus"
                  width="100"
                  show-overflow-tooltip
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.biddingStatus == 'N'">未竞价</span>
                    <span v-if="scope.row.biddingStatus == 'Y'">已竞价</span>
                  </template>
                </el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="biddingPrice"
                  align="center"
                  label="最终报价(元/吨)"
                  width="150"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="rank"
                  align="center"
                  label="名次"
                ></el-table-column>
                <el-table-column show-overflow-tooltip align="center" prop="brand" label="货物品牌"></el-table-column>
                <el-table-column show-overflow-tooltip align="center" prop="dailyOutput" label="规格"></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="product"
                  align="center"
                  label="产品大类"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="kind"
                  align="center"
                  label="品种"
                ></el-table-column>
                <!-- <el-table-column show-overflow-tooltip align="center" prop="goodsCode" label="货物编码"></el-table-column> -->
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  prop="transportType"
                  label="运输类型"
                ></el-table-column>
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="transportMode"
                  align="center"
                  label="运输方式"
                ></el-table-column>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  prop="transportQuantity"
                  label="运输数量(吨)"
                  width="120"
                ></el-table-column>
                <!-- <el-table-column show-overflow-tooltip align="center" prop="specialRequire" label="特殊要求"></el-table-column> -->
                <!-- <el-table-column show-overflow-tooltip align="center" width="120" prop="dptName" label="需求来源"></el-table-column> -->
                <el-table-column
                  size="mini"
                  show-overflow-tooltip
                  prop="remark"
                  align="center"
                  label="备注"
                ></el-table-column>
                <el-table-column show-overflow-tooltip align="center" label="操作">
                  <template slot-scope="scope">
                    <el-button
                      size="mini"
                      type="primary"
                      plain
                      @click="showTransportMethod(scope.row)"
                    >线路详情</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <!-- <div>
                <el-pagination class="pagination" small background
                  @size-change="handleSizeChangeA"
                  @current-change="handleCurrentChangeA"
                  :current-page="currentPage"
                  :page-sizes="[30, 60, 90, 120]"
                  :page-size="30"
                  layout="sizes, prev, pager, next, jumper, total"
                  :total="pageTotal">
                </el-pagination>
              </div>-->
            </div>
          </template>
        </split-pane>
      </div>
    </template>
    <!-- 竞价信息弹框 -->
    <el-dialog
      width="80%"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      v-el-drag-dialog
      title="竞价室"
      :visible.sync="RefTypeDialogVisible"
      v-if="RefTypeDialogVisible"
      :before-close="handleTypeDialogClose"
    >
      <div class="titleq" :model="oneBiddingListA">
        <div class="titleA">
          <span>投标现场</span>
          <span>【{{ oneBiddingListA.bidEdited }}】-</span>
          <span>【{{ oneBiddingListA.bidType }}】-</span>
          {{ oneBiddingListA.bidName }}
          <span></span>
        </div>
        <div class="tu">
          <img src="@/assets/images/tubiao/HZ.png" />
        </div>
        <div class="righg">
          <span>标的编号 : {{ oneBiddingListA.bidCode }}</span>
        </div>
      </div>
      <div class="heis" :model="oneBiddingListA">
        <!-- <div class="biao">您的当前出价排名: <span id="renk1">{{oneBiddingListA.rank}}</span></div> -->
        <div class="left">开始竞价时间：{{ oneBiddingListA.bidBiddingStart }}</div>
        <div class="sysj">
          【{{ bidStatus }}】剩余出价时间:{{ box }}
          <img src="@/assets/images/tubiao/SL.png" alt />
        </div>
        <!-- <div class="sysj">【{{bidStatus}}】剩余出价时间:<down :endTime="endTimeA" :startTime="startTime" :callback="callback" endText="00:00:00:00"></down> <img src="@/assets/images/tubiao/SL.png" alt=""></div> -->
        <div class="rigth">截止竞价时间：{{ oneBiddingListA.bidBiddingEnd }}</div>
      </div>
      <div class="fooer"></div>
      <el-table
        :data="oneBiddingList"
        border
        highlight-current-row
        :height="biddingHeight"
        :header-cell-style="{
          textAlign: 'center'
        }"
        :cell-style="{}"
      >
        <el-table-column
          size="mini"
          show-overflow-tooltip
          prop="bidCode"
          width="160"
          align="center"
          label="标的编号"
        ></el-table-column>
        <el-table-column
          size="mini"
          show-overflow-tooltip
          prop="bidName"
          width="220"
          align="center"
          label="标的名称"
        ></el-table-column>
        <el-table-column
          align="center"
          label="标的状态"
          prop="bidStatus"
          width="160"
          show-overflow-tooltip
        ></el-table-column>
        <!-- <el-table-column align="center" label="竞价状态" prop="biddingStatus" width="160" show-overflow-tooltip>
                <template slot-scope="scope">
                    <span v-if="scope.row.biddingStatus =='N'">未竞价</span>
                    <span v-if="scope.row.biddingStatus =='Y'">已竞价</span>
                  </template>
        </el-table-column>-->
        <el-table-column
          size="mini"
          show-overflow-tooltip
          prop="bidType"
          width="160"
          align="center"
          label="标的类型"
        ></el-table-column>
        <!-- <el-table-column size="mini" show-overflow-tooltip prop="bidAmount"  width="160" align="center" label="运输总量（吨）"></el-table-column> -->
        <!-- <el-table-column size="mini" show-overflow-tooltip prop="bidSignupStart"  align="center" label="竞价报名开始时间"></el-table-column>
        <el-table-column size="mini" show-overflow-tooltip prop="bidSignupEnd" align="center" label="竞价报名结束时间"></el-table-column>-->
        <el-table-column
          size="mini"
          show-overflow-tooltip
          prop="bidBiddingStart"
          width="160"
          align="center"
          label="竞价开始时间"
        ></el-table-column>
        <el-table-column
          size="mini"
          show-overflow-tooltip
          prop="bidBiddingEnd"
          width="160"
          align="center"
          label="竞价结束时间"
        ></el-table-column>
        <el-table-column
          size="mini"
          show-overflow-tooltip
          prop="bidOffer"
          align="center"
           width="250"
          label="单价竞价范围（元/吨）"
        ></el-table-column>
        <!-- <el-table-column size="mini" show-overflow-tooltip prop="bidQuotations"  align="center" label="竞价方式"></el-table-column> -->
        <!-- <el-table-column show-overflow-tooltip align="center" width="120" prop="dptName" label="标的来源"></el-table-column> -->
        <el-table-column
          size="mini"
          show-overflow-tooltip
          header-align="left"
          align="left"
          prop="bidRemark"
          width="250"
          label="备注"
        ></el-table-column>
      </el-table>
      <div class="codeNumberCode" style="background-color: #fff;">需求信息</div>
      <div class="btn-area" ref="detlArea">
        <el-button plain size="mini" type="primary" @click="importExcel">导入</el-button>
        <el-button plain size="mini" type="primary" @click="outExcel">导出</el-button>
      </div>
      <el-table
        :data="oneSugarList"
        highlight-current-row
        border
        :height="biddingSugarHeight"
        :header-cell-style="{
          textAlign: 'center'
        }"
        :cell-style="{}"
      >
        <el-table-column
          show-overflow-tooltip
          type="index"
          :index="indexMethodDet"
          label="序号"
          width="60"
          align="center"
        ></el-table-column>
        <el-table-column
          size="mini"
          show-overflow-tooltip
          width="120"
          align="left"
          prop="demandCode"
          label="需求编号"
        ></el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          prop="transportQuantity"
          label="运输数量(吨)"
        ></el-table-column>
        <el-table-column size="mini" show-overflow-tooltip prop="kind" align="center" label="品种"></el-table-column>
        <el-table-column show-overflow-tooltip align="center" prop="dailyOutput" label="规格"></el-table-column>
        <!-- <el-table-column
          show-overflow-tooltip
          align="center"
          width="120"
          prop="dptName"
          label="需求来源"
        ></el-table-column>-->
        <el-table-column show-overflow-tooltip align="center" prop="brand" label="货物品牌"></el-table-column>
        <el-table-column
          align="center"
          label="竞价状态"
          prop="biddingStatus"
          width="160"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span v-if="scope.row.biddingStatus == 'N'">未竞价</span>
            <span v-if="scope.row.biddingStatus == 'Y'">已竞价</span>
          </template>
        </el-table-column>
        <el-table-column
          size="mini"
          show-overflow-tooltip
          prop="biddingPrice"
          align="center"
          label="当前出价(元/吨)"
        >
          <template slot-scope="scope">
            <span id="renk3">{{ scope.row.biddingPrice }}</span>
          </template>
        </el-table-column>
        <el-table-column size="mini" show-overflow-tooltip prop="rank" align="center" label="当前名次">
          <template slot-scope="scope">
            <span id="renk2">{{ scope.row.rank }}</span>
          </template>
        </el-table-column>
        <!-- <el-table-column size="mini" show-overflow-tooltip prop="product" align="center" label="产品大类"></el-table-column> -->
        <!-- <el-table-column show-overflow-tooltip align="center" prop="transportType" label="运输类型"></el-table-column> -->
        <!-- <el-table-column size="mini" show-overflow-tooltip prop="transportMode"  align="center" label="运输方式"></el-table-column> -->
        <!-- <el-table-column size="mini" show-overflow-tooltip prop="remark" align="center" label="备注"></el-table-column> -->
        <el-table-column show-overflow-tooltip align="center" label="操作">
          <template slot-scope="scope">
            <el-button size="mini" type="primary" plain @click="queryDemand(scope.row)">详情</el-button>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          width="180"
          prop="biddingPrices"
          label="出价(元/吨)"
        >
          <template slot-scope="scope">
            <el-input-number
              controls-position="right"
              style="width:98%"
              :step="priceStep"
              size="mini"
              @input="inOfeer(scope.row)"
              v-model="scope.row.biddingPrices"
            ></el-input-number>
          </template>
          <!-- <el-input  size="mini" style="width: 100%"></el-input> -->
        </el-table-column>
        <!-- <el-table-column size="mini" show-overflow-tooltip prop="minPrice"  align="center" label="最低出价"></el-table-column> -->
        <!-- <el-table-column size="mini" show-overflow-tooltip prop="bidAppointMan" align="left" label="供应商指定人"></el-table-column> -->
      </el-table>
      <!-- <div class="tableTitle">需求信息</div>
        <div>
          <el-table :data="currentCodeList" :height="detlHeight" highlight-current-row border
            :header-cell-style="{
              textAlign: 'center'
            }" :cell-style="{}" >
            <el-table-column show-overflow-tooltip type="index" :index="indexMethodDet" label="序号" width="60" align="center"></el-table-column>
            <el-table-column size="mini" show-overflow-tooltip  width="120" align="left" prop="demandCode" label="需求编号"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="brand" label="货物品牌"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="dailyOutput" label="规格"></el-table-column>
            <el-table-column size="mini" show-overflow-tooltip prop="product" align="center" label="产品大类"></el-table-column>
            <el-table-column size="mini" show-overflow-tooltip prop="kind" align="center" label="品种"> </el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="transportType" label="运输类型"></el-table-column>
            <el-table-column size="mini" show-overflow-tooltip prop="transportMode"  align="center" label="运输方式"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="transportQuantity" label="运输数量(吨)"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" width="120" prop="dptName" label="需求来源"></el-table-column>
            <el-table-column size="mini" show-overflow-tooltip prop="remark" align="center" label="备注"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" label="操作">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="primary"
                  plain
                  @click="showTransportMethod(scope.row)"
                >线路详情</el-button>
              </template>
            </el-table-column>
          </el-table>
      </div>-->
      <br />
      <el-form :model="RefTypeData" ref="RefTypeData" :rules="RefTypeDataRules" label-width="10rem">
        <el-row>
          <!-- <el-col :span="8">
                <el-form-item label="报价(元/吨):" prop="biddingPrice">
                  <el-input maxlength="10"  style="width:100%" @change="inOfeer" v-model="RefTypeData.biddingPrice"></el-input>
                </el-form-item>
          </el-col>-->

          <el-col :span="1">
            <span style="width:100%" />&nbsp;
          </el-col>
          <el-col :span="5">
            <h2>投标状态：{{ bidStatus }}</h2>
          </el-col>
          <!--<el-col :span="2">
                  <el-button type="primary" v-if="isAuth('biddingButtonC')"  @click="stopBidding">{{biddingStopOrBegin}}</el-button>
          </el-col>-->
          <el-col :span="10">
            <span style="width:100%" />&nbsp;
          </el-col>
          <el-col :span="2">
            <el-button type="primary" @click="refreshHome">刷新竞标室</el-button>
          </el-col>
          <el-col :span="1">
            <span style="width:100%" />&nbsp;
          </el-col>
          <el-col :span="2">
            <el-button type="primary" @click="outBidding">退出竞标室</el-button>
          </el-col>
          <el-col :span="1">
            <span style="width:100%" />&nbsp;
          </el-col>
          <el-col :span="2">
            <el-button type="primary" @click="biddingTrue">更新报价</el-button>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>

    <el-dialog
      width="40%"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      v-el-drag-dialog
      title="线路详情"
      :visible.sync="tranDialogInfoDialogVisible"
      v-if="tranDialogInfoDialogVisible"
    >
      <el-table
        :data="tranDialogInfoList"
        :height="detlHeight"
        highlight-current-row
        border
        :header-cell-style="{
          textAlign: 'center'
        }"
        :cell-style="{}"
      >
        <el-table-column type="index" width="60" align="center" label="序号"></el-table-column>
        <el-table-column show-overflow-tooltip align="center" label="起始地" prop="site"></el-table-column>
        <el-table-column show-overflow-tooltip align="center" label="目的地" prop="destination"></el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          @click="
            tranDialogInfoDialogVisible = false
            tranDialogInfoList = []
          "
        >关闭</el-button>
      </span>
    </el-dialog>

    <el-dialog title="导入出价信息" :visible.sync="openDialog" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button @click="openDialog = false">取 消</el-button>
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog
      width="58%"
      top="5vh"
      v-dialogDrag
      v-el-drag-dialog
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      v-if="showDialog"
      :visible.sync="showDialog"
      :title="operate"
    >
      <el-form
        ref="basicForm"
        :model="currentFltInfo"
        label-width="15rem"
        inline="true"
        size="mini"
      >
        <el-row>
          <el-form-item label="需求编号:" prop="demandCode">
            <el-input readonly="ture" v-model="currentFltInfo.demandCode" style="width:50"></el-input>
          </el-form-item>
          <el-form-item label="货物品牌:" prop="goodBrand">
            <el-input readonly="ture" v-model="currentFltInfo.brand"></el-input>
          </el-form-item>
          <el-form-item label="规格:" prop="dailyOutput">
            <el-input readonly="ture" v-model="currentFltInfo.dailyOutput"></el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="产品大类:" prop="projuctBig">
            <el-input readonly="ture" v-model="currentFltInfo.product"></el-input>
          </el-form-item>
          <el-form-item label="品种:" prop="kind">
            <el-input readonly="ture" v-model="currentFltInfo.kind"></el-input>
          </el-form-item>
          <el-form-item label="结算方式:" prop="settlementWay">
            <el-input readonly="ture" v-model="currentFltInfo.settlementWay"></el-input>
          </el-form-item>
          <el-form-item label="货物编码:" prop="goodCode" v-if="false">
            <el-input readonly="ture" v-model="currentFltInfo.goodCode"></el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="运输类型:" prop="transportType">
            <el-input readonly="ture" v-model="currentFltInfo.transportType"></el-input>
          </el-form-item>
          <el-form-item label="运输方式:" prop="transportMode">
            <el-input readonly="ture" v-model="currentFltInfo.transportMode"></el-input>
          </el-form-item>
          <el-form-item label="运输数量(吨):" prop="transportQuantity">
            <el-input readonly="ture" v-model="currentFltInfo.transportQuantity"></el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="履约保证金（元）:" prop="performanceBond">
            <el-input readonly="ture" v-model="currentFltInfo.performanceBond"></el-input>
          </el-form-item>
          <el-form-item label="要求开始时间:" prop="requiredStartTime">
            <el-input readonly="ture" v-model="currentFltInfo.requiredStartTime"></el-input>
          </el-form-item>
          <el-form-item label="要求完成天数:" prop="requiredEndDay">
            <el-input readonly="ture" v-model="currentFltInfo.requiredEndDay"></el-input>
          </el-form-item>
        </el-row>

        <el-row>
          <el-col :span="22">
            <el-form-item label="备注:" prop="remark">
              <el-input
                readonly="ture"
                type="textarea"
                v-model="currentFltInfo.remark"
                style="width: 500px"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!-- 弹窗下方线路信息模块 -->

      <el-table
        :data="tranDialogInfoList"
        :height="detlHeight"
        highlight-current-row
        border
        :header-cell-style="{
          textAlign: 'center'
        }"
        :cell-style="{}"
      >
        <el-table-column type="index" width="60" align="center" label="序号"></el-table-column>
        <el-table-column show-overflow-tooltip align="center" label="起始地" prop="site"></el-table-column>
        <el-table-column show-overflow-tooltip align="center" label="目的地" prop="destination"></el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          @click="
            showDialog = false
            tranDialogInfoList = []
            currentFltInfo = []
          "
        >关闭</el-button>
      </span>
    </el-dialog>

    <el-dialog
      v-dialogDrag
      v-el-drag-dialog
      :visible.sync="stepDialog.show"
      :title="stepDialog.title"
      width="300px"
      @open="stepDialogOpen"
    >
      <div>
        <el-form :model="stepDialog.data" :rules="stepDialog.rules" ref="stepFromRef">
          <el-form-item prop="step" size="mini" label="步调：" label-width="80px">
            <el-input v-model="stepDialog.data.step" style="width: 160px" placeholder="请输入"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="stepDialog.show = false">取 消</el-button>
        <el-button type="primary" @click="doUpdateStep">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {
  queryBiddingList,
  auditBiddingMethod,
  bidListDetail,
  signupBiddingMethod,
  delSignupMethod,
  selectBiddingInfo,
  biddingInfoMethod,
  queryBiddingInfo,
  querybiddingInfoData,
  queryDemandLine,
  queryDemandList,
  quertLineInfo,
  queryNowTime,
  querytSignUpSugar,
  haveBiddingPrice,
  delBiddingMethod,
  stopBiddingStatus
} from '@/request/api'
import resizeMixin from '@/mixins/resize'
import isAuth from '@/mixins/buttonAuth'
import paginationMixin from '@/mixins/pagination'
import store from '@/store'
import VDialog from './dialog'
import { getToken } from '@/request/http'
import down from '@/components/countDown'
import scrollChange from '@/utils/onscroll.js'
import buttonName from '@/components/buttonName/button-name.vue'
export default {
  mixins: [resizeMixin, paginationMixin, isAuth],
  components: {
    down,
    buttonName
  },
  data() {
    var RVNAME = (rule, value, callback) => {
      // 获得字符串实际长度，中文2，英文1
      var realLength = 0,
        len = value.length,
        charCode = -1
      for (var i = 0; i < len; i++) {
        charCode = value.charCodeAt(i)
        if (charCode >= 0 && charCode <= 128) realLength += 1
        else realLength += 2
      }
      if (realLength > 32) {
        return callback(new Error('最多为32位'))
        // this.companyName = cutstr(this.companyName, 60);
      } else {
        return callback()
      }
    }
    var RVREMARK = (rule, value, callback) => {
      // 获得字符串实际长度，中文2，英文1
      var realLength = 0,
        len = value.length,
        charCode = -1
      for (var i = 0; i < len; i++) {
        charCode = value.charCodeAt(i)
        if (charCode >= 0 && charCode <= 128) realLength += 1
        else realLength += 2
      }
      if (realLength > 128) {
        return callback(new Error('最多为128位'))
        // this.companyName = cutstr(this.companyName, 60);
      } else {
        return callback()
      }
    }
    return {
      priceStep: 0.5,
      endText: '00:00:00:00',
      endTimeA: '',
      startTime: '',
      box: '',
      nowtime: '',
      dateList: '',
      timer: '',
      refresh: '',
      showDialog: false,
      operate: '',
      currentFltInfo: {},
      queryParam: {
        bidCode: '', // 标的编号
        biddingStatus: '' // 标的竞价状态
      },
      biddingStopOrBegin: '', //暂停竞价按钮显示为暂停竞价或是开始竞价
      diaTableData: [], // 弹出框需求信息信息
      statusList: [
        { code: 'N', name: '未竞价' },
        { code: 'Y', name: '已竞价' }
      ],
      kinds: {
        BROW: '赤砂糖',
        TWOW: '二级白砂糖',
        ONEW: '一级白砂糖'
      },
      selApproveArray: [], //多选框信息
      sugarIds: [], //需求id数组
      currentPage: 1,
      pageSize: 30,
      pageTotal: 0,

      currentRow: '',
      codeentRow: '',
      typeHeight: -1,
      detlHeight: -1,
      biddingHeight: -1,
      biddingSugarHeight: -1,
      CodeRCTUUID: false,
      CodeRVDOMAIN: false,
      checkedY: true,
      checkedN: false,
      flt: {
        rvDomain: '',
        rvName: ''
      },
      copyDomain: '',
      copyName: '',
      rleTypes: [],
      TypeMap: {
        updateType: 'baseCode.editClassify',
        createType: 'baseCode.addClassify'
      },
      CodeMap: {
        updateCode: 'baseCode.editCode',
        createCode: 'baseCode.addCode'
      },
      TypeDialogStatus: '',
      CodeDialogStatus: '',
      currentNode: {},
      currentType: {},
      TypeList: [],
      currentCodeList: [],
      currentCode: {},
      biddingCodeList: {},
      biddingInfoData: {}, //第几轮报价详细信息
      tranDialogInfoList: [],
      oneBiddingList: [], //竞价室标信息
      oneBiddingListA: [],
      oneSugarList: [], //竞价室需求信息
      tranDialogInfoDialogVisible: false, //线路详情Dialog
      RefTypeDialogVisible: false, // 竞价 Dialog
      RefCodeDialogVisible: false, // 基础代码 Dialog
      biddingInfoList: false, //查看竞价信息
      bidStatus: '', //投标状态

      openDialog: false, //导入弹框
      // 导入
      upload: {
        isUploading: false,
        headers: '',
        url: (process.env.NODE_ENV === 'production' ? '/' : '/proxy/') + 'FTKJWLHYPT/bidAdminister/importBiddingPrice'
      },

      dialogForm: {},
      dialogText: {
        title: '',
        show: false,
        button: {
          t: '',
          f: ''
        },
        qeuryButtonShow: false,
        paginationShow: false
      },
      // 代码分类
      RefTypeData: {}, // 代码分类 dialog内的form([A-Z]|\d)[0-9a-zA-Z]
      rules: {
        RV_DOMAIN: [
          { min: 1, max: 4, message: '至多输入4 个字符', trigger: 'change' },
          {
            pattern: /^([^\u4e00-\u9fa5])+$/,
            message: '禁止输入中文',
            trigger: 'change'
          }
        ],
        RV_NAME: [
          { validator: RVNAME, trigger: 'change' },
          {
            pattern: /^([0-9a-zA-Z\u4e00-\u9fa5])+$/,
            message: '只能输入中文字母数字',
            trigger: 'change'
          }
        ]
      },
      RefTypeDataRules: {
        biddingPrices: [
          { required: true, message: '请填写报价', trigger: 'blur' },
          {
            pattern: /^\d+\.?(\d{1,2})?$/,
            message: '只能输入数字和两位小数',
            trigger: 'change'
          }
        ]
      },
      // 基础代码
      RefCodeData: {}, // 代码分类 dialog内的form
      RefCodeDataRules: {
        rvDomain: [{ required: true, message: '请选择代码类型', trigger: 'change' }],
        rvLowValue: [
          { min: 1, max: 4, message: '至多输入4个字符', trigger: 'change' },
          {
            pattern: /^([^\u4e00-\u9fa5])+$/,
            message: '禁止输入中文',
            trigger: 'change'
          },
          { required: true, message: '请填写代码编号', trigger: 'blur' }
        ],
        rvCmeaning: [
          { required: true, message: '请填写代码名称', trigger: 'blur' },
          { validator: RVNAME, trigger: 'change' }
          // {
          //   pattern: /^([0-9a-zA-Z\u4e00-\u9fa5])+$/,
          //   message: '只能输入中文字母数字',
          //   trigger: 'change'
          // }
        ],
        rvIsvalid: [{ required: true, message: '请选择有效标志', trigger: 'blur' }]
      },
      stepDialog: {
        show: false,
        title: '微调价格',
        data: {
          step: undefined
        },
        rules: {
          step: [
            { required: true, message: '请输入步长', trigger: ['blur'] },
            { pattern: /^0\.[1-9]$/, message: '请输入0 - 1之间的数字', trigger: 'change' }
          ]
        }
      }
    }
  },
  created() {
    this.resize = () => {
      this.typeHeight = this.$refs.topType.offsetHeight - 80
      // 70
      this.detlHeight = this.$refs.bottomCode.offsetHeight - 70

      this.biddingHeight = this.$refs.bottomCode.offsetHeight - 120

      this.biddingSugarHeight = this.$refs.bottomCode.offsetHeight - 30
      // 130
    }
  },
  mounted() {
    let demandWrapper = document.querySelector('.demand .el-table__body-wrapper') // 新增滚动条监听事件
    scrollChange(demandWrapper)
  },
  beforeMount() {
    this.refreshList()
  },
  computed: {
    grandson() {
      var dataList = []
      var number
      var arr = this.$route.path.split('/')
      number = arr.length - 1
      dataList = this.$store.state.user.permList
      for (var i = 0; i < dataList.length; i++) {
        for (var f = 0; f < dataList[i].Children.length; f++) {
          if (dataList[i].Children[f].MDL_CODE == arr[number]) {
            return dataList[i].Children[f].Grandson
          }
        }
      }
      return []
    },
    disableType() {
      return this.TypeDialogStatus === 'updateType'
    }
  },
  methods: {
    //调取父组件方法
    clickEventDom(item) {
      if (item.mdlCode === 'biddingButton') {
        this.biddingButton()
      } else if (item.mdlCode === 'delbiddingButton') {
        this.delbiddingButton()
      } else if (item.mdlCode === 'biddingButtonB') {
        this.outExcel()
      }
    },
    aaaa() {
      // this.endTimeA = this.dateList
      // this.startTime = '2020-07-26 19:24:00'
      this.timer = setInterval(this.fn, 1000)
      // this.countdowm()
    },
    // countdowm(){
    //   let self = this;
    //   var box = self.dateList
    //   var boxa = self.nowtime
    //   var a = '2020-07-26 19:24:00'
    //   var b = Number(a)
    //   let timer = setInterval(function(){
    //     let nowTimea = new Date();
    //     let endTime = new Date(box);
    //     let t = endTime.getTime() - nowTimea.getTime();
    //     if(t>0){
    //       let day = Math.floor(t/86400000);
    //       let hour=Math.floor((t/3600000)%24);
    //       let min=Math.floor((t/60000)%60);
    //       let sec=Math.floor((t/1000)%60);
    //       hour = hour < 10 ? "0" + hour : hour;
    //       min = min < 10 ? "0" + min : min;
    //       sec = sec < 10 ? "0" + sec : sec;
    //       let format = '';
    //        format = `${day}:${hour}:${min}:${sec}`;
    //       self.box = format;
    //       }else{
    //        clearInterval(timer);
    //        self.box = self.endText;
    //        self._callback();
    //       }
    //      },1000);
    //     },
    //     _callback(){
    //     if(this.callback && this.callback instanceof Function){
    //        this.callback(...this);
    //      }
    //   },
    fn() {
      var box = this.dateList
      var future = new Date(box)
      var nowtime = new Date(this.nowtime)
      var t = future.getTime() - nowtime.getTime()
      if (t > 0) {
        var day = Math.floor(t / 86400000)
        var hour = Math.floor((t / 3600000) % 24)
        var minu = Math.floor((t / 60000) % 60)
        var sec = Math.floor((t / 1000) % 60)

        day = day < 10 ? '0' + day : day
        hour = hour < 10 ? '0' + hour : hour
        minu = minu < 10 ? '0' + minu : minu
        sec = sec < 10 ? '0' + sec : sec
        this.box = day + ':' + hour + ':' + minu + ':' + sec //天时分秒
        this.nowtime = nowtime.getTime() + 1000
      } else {
        window.clearInterval(this.timer)
        window.clearInterval(this.refresh)
        this.box = this.endText
        this.biddingHome()
        return
      }

      //  this.box = hour+":"+minu+":"+sec; // 时分秒
      //时间到'00:00:00:00'时 清除定时器
      //  if(this.box === '00:00:00:00'){
      //     clearInterval(this.timer);
      //     // document.getElementById("renk1").style.color="red";
      //     // document.getElementById("renk2").style.color="red";
      //     // document.getElementById("renk3").style.color="red";

      //   }
    },
    // 关闭弹窗
    closeEdit() {
      this.showDialog = false
    },
    dialogBeforeClose(done) {
      this.$confirm('确认关闭?')
        .then(() => {
          done()
        })
        .catch(() => {})
    },

    checkCode() {
      this.flt.RV_DOMAIN = this.flt.RV_DOMAIN.replace(/[^a-zA-Z]/g, '')
    },
    typecheck() {
      this.RefTypeData.RV_DOMAIN = this.RefTypeData.RV_DOMAIN.replace(/[^a-zA-Z]/g, '')
    },
    codecheck() {
      this.RefCodeData.RV_DOMAIN = this.RefCodeData.RV_DOMAIN.replace(/[^a-zA-Z]/g, '')
    },
    uppercase(key) {
      this.$refs.typePagination.lastEmittedPage = 1
      this.$refs.codePagination.lastEmittedPage = 1
      this.flt[key] = this.flt[key].toUpperCase()
    },
    // typeuppercase(key) {
    //   this.RefTypeData[key] = this.RefTypeData[key].toUpperCase()
    // },
    codeuppercase(key) {
      this.RefCodeData[key] = this.RefCodeData[key].toUpperCase()
    },
    getFltType() {
      addCodeTableXL({}).then(res => {
        if (res.success === '1') {
          this.rleTypes = res.data
        }
      })
    },
    searchType() {
      this.$refs.queryParam.validate(valid => {
        if (valid) {
          this.Pagination.currentPage = 1
          this.getList(this.Pagination.currentPage, this.Pagination.pageSize, this.updatePaginationTotal)
        }
      })
    },
    //获取列表
    getList(currentPage, pageSize, updateTotal) {
      this.currentCodeList = []
      this.currentCode = []
      this.RefTypeData = {}
      queryBiddingList({
        bidCode: this.queryParam.bidCode,
        biddingStatus: this.queryParam.biddingStatus,
        bidAuditstatus: 'Y',
        bidBiddingstatus: 'Y',
        enrollStatus: 'Y',
        PageIndexs: this.Pagination.currentPage.toString(),
        PageSizes: this.Pagination.pageSize.toString()
      }).then(response => {
        this.TypeList = response.data
        updateTotal(Number(response.total))
      })
    },

    //判断报价是否在报价范围内
    inOfeer(row) {
      var regStrs = [
        ['[^\\d\\.]+$', ''], //禁止录入任何非数字和点
        ['\\.(\\d?)\\.+', '.$1'], //禁止录入两个以上的点
        ['^(\\d+\\.\\d{2}).+', '$1'] //禁止录入小数点后两位以上
      ]
      for (var i = 0; i < regStrs.length; i++) {
        var reg = new RegExp(regStrs[i][0])
        row.biddingPrices = row.biddingPrices.replace(reg, regStrs[i][1])
      }
      // if(row.biddingPrices < this.RefTypeData.bidOfferStart
      // || row.biddingPrices > this.RefTypeData.bidOfferEnd ){
      //   this.$alert("需求编号为：" + row.demandCode + ',出价要在规定的报价范围内才有效！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   row.biddingPrices = ''
      //   return
      // }
      // if(row.biddingPrice && row.biddingPrices > row.biddingPrice){
      //   this.$alert("需求编号为：" + row.demandCode + ',更新报价只能比当前出价要低！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //       row.biddingPrices = ''
      //       return
      // }
      // if(row.biddingPrices && row.biddingPrices!= row.biddingPrice){
      //   haveBiddingPrice({sugarId:row.sugarId,
      //     biddingPrices:row.biddingPrices,
      //     bidId:this.RefTypeData.bidId
      //     }).then(res => {
      //       if (res.msg!='成功！') {
      //         this.$alert("需求编号为：" + row.demandCode + ',该报价已存在', '提示', {
      //           confirmButtonText: '确定'
      //         })
      //           row.biddingPrices = ''
      //           return
      //       }
      //   })
      // }
    },

    // 竞价
    biddingButton() {
      if (Object.keys(this.RefTypeData).length == 0) {
        this.$alert('请选择需要竞价的信息！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      if (this.RefTypeData.bidStopStatus === 'Y') {
        this.$alert('该信息已暂停竞价！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      if (this.RefTypeData.bidStopStatus === 'Y') {
        this.biddingStopOrBegin = '开始竞价'
      } else {
        this.biddingStopOrBegin = '暂停竞价'
      }
      //查看报价（第几轮）详细信息
      // this.biddingInfoData = {},
      // querybiddingInfoData({biddingId:this.RefTypeData.biddingId}).then(res=>{
      //   if(res.success==='1'){
      //     this.biddingInfoData = res.data
      //     this.RefTypeDialogVisible = true
      //   }
      // })
      //  queryBiddingList({
      //   bidCode:this.queryParam.bidCode,
      //   biddingStatus:this.queryParam.biddingStatus,
      //   bidAuditstatus:'Y',
      //   bidBiddingstatus:'Y',
      //   enrollStatus:'Y',
      //   bidId:this.RefTypeData.bidId,
      //   PageIndexs: this.Pagination.currentPage.toString(),
      //   PageSizes: this.Pagination.pageSize.toString()
      //   }).then(response => {
      //     this.oneBiddingList = response.data
      //     this.oneBiddingListA = response.data[0]
      //     this.dateList = response.data[0].bidBiddingEnd
      //   })
      querytSignUpSugar({
        bidId: this.RefTypeData.bidId,
        signupStatus: 'Y'
        // sugarId: this.currentCode.sugarId
      }).then(res => {
        if (res.success == 1) {
          this.currentCodeList = res.data
          this.oneSugarList = res.data
          this.oneBiddingListA.rank = res.data[0].rank
          this.RefTypeData.biddingPrice = res.data[0].biddingPrice
        }
      })
      this.oneBiddingList = []
      this.oneBiddingList.push(this.RefTypeData)
      this.oneBiddingListA = this.RefTypeData
      this.dateList = this.RefTypeData.bidBiddingEnd
      this.bidStatus = this.RefTypeData.bidStatus
      queryNowTime().then(res => {
        if (res.success === '1') {
          this.nowtime = res.data
          let date = new Date(this.nowtime)
          let startime = new Date(Date.parse(this.RefTypeData.bidBiddingStart))
          let endtime = new Date(Date.parse(this.RefTypeData.bidBiddingEnd))
          if (this.RefTypeData.bidStopStatus === 'N') {
            if (startime > date) {
              this.$alert('该竞价还未开始，敬请期待！', '提示', {
                confirmButtonText: '确定'
              })
              this.RefTypeDialogVisible = false
              return
            }
            if (date > endtime) {
              this.$alert('十分抱歉，该竞价已经结束', '提示', {
                confirmButtonText: '确定'
              })
              this.RefTypeDialogVisible = false
              return
            }
          }
          this.RefTypeDialogVisible = true
        }
        this.aaaa()
        this.refresh = setInterval(this.refreshRank, 30000)
      })
    },

    queryDemand(value) {
      this.operate = '需求详细信息'
      querytSignUpSugar({ sugarId: value.sugarId, bidId: this.RefTypeData.bidId }).then(res => {
        if (res.success === '1') {
          this.currentFltInfo = res.data[0]
          queryDemandLine({
            sugarId: value.sugarId
          }).then(res => {
            if (res.success == 1) {
              this.tranDialogInfoList = res.data
            }
          })
          this.showDialog = true
        } else {
          this.$message.error({
            message: '操作失败'
          })
        }
      })
      // this.currentFltInfo = Object.assign({}, value)
    },

    // 取消竞价
    delbiddingButton() {
      if (Object.keys(this.RefTypeData).length == 0) {
        this.$alert('请选择需要取消竞价的信息！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      var ststus = []
      this.currentCodeList.forEach(element => {
        if (element.biddingStatus === 'Y') {
          ststus.push(element.biddingStatus)
        }
      })
      if (ststus.length == 0) {
        this.$alert('该需求信息中不存在可取消的已竞价信息！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      this.$confirm('您确定要取消竞价该信息吗？', '提示', {
        confirmButtonText: '确定'
      }).then(() => {
        queryNowTime().then(res => {
          if (res.success === '1') {
            this.nowtime = res.data - 1000
            let date = new Date(this.nowtime)
            let startime = new Date(Date.parse(this.RefTypeData.bidBiddingStart))
            let endtime = new Date(Date.parse(this.RefTypeData.bidBiddingEnd))
            if (startime > date) {
              this.$alert('该竞价还未开始，敬请期待！', '提示', {
                confirmButtonText: '确定'
              })
              return
            }
            if (date > endtime) {
              this.$alert('十分抱歉，该竞价已经结束', '提示', {
                confirmButtonText: '确定'
              })
              return
            }
            delBiddingMethod({ bidId: this.RefTypeData.bidId, biddingStatus: 'N' }).then(res => {
              if (res.success === '1') {
                this.$message({
                  type: 'success',
                  message: '取消竞价成功'
                })
                this.RefTypeDialogVisible = false
                this.refreshList()
              }
            })
          }
        })
      })
    },

    //导出
    outExcel() {
      if (this.currentCodeList.length == 0) {
        this.$alert('请选择需要导出的信息！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      var filename = this.RefTypeData.bidCode + '-' + this.RefTypeData.bidName
      import('@/vendor/Export2Excel').then(excel => {
        const tHeader = ['序号', '需求编号', '吨数', '品种', '规格', '来源', '品牌', '竞价状态', '当前出价', '当前名次', '起始地', '目的地']
        const filterVal = ['index', 'demandCode', 'transportQuantity', 'kind', 'dailyOutput', 'dptName', 'brand', 'biddingStatus', 'biddingPrice', 'rank', 'site', 'destination']
        const list = this.currentCodeList
        const data = this.formatJson(filterVal, list)
        excel.export_json_to_excel({
          header: tHeader,
          data,
          filename: filename,
          autoWidth: true
        })
        this.downloadLoading = false
      })
    },
    formatJson(filterVal, jsonData) {
      return jsonData.map((v, index) =>
        filterVal.map(j => {
          if (j === 'biddingStatus') {
            if (v[j] === 'Y') {
              return '已竞价'
            } else {
              return '未竞价'
            }
          }
          if (j === 'index') {
            return index + 1
          }
          return v[j]
        })
      )
    },

    //导入
    importExcel() {
      this.upload.headers = { bidId: this.RefTypeData.bidId, fltId: store.state.user.FLT_UUID_DX_H, Token: getToken() }
      this.openDialog = true
    },
    //提交
    submitFileForm() {
      this.$refs.upload.submit()
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.openDialog = false
      this.upload.isUploading = false
      this.$refs.upload.clearFiles()
      // this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      // this.getList();
      if (response.success === '1') {
        this.$message.success('导入成功')
        this.oneSugarList = response.data
      } else {
        this.$message.error(response.msg)
      }
    },

    //暂停竞价
    stopBidding() {
      window.clearInterval(this.timer)
      if (this.RefTypeData.bidStopStatus === 'Y') {
        var status = 'N'
      } else {
        var status = 'Y'
      }
      stopBiddingStatus({
        bidId: this.RefTypeData.bidId,
        box: this.box,
        bidBiddingEnd: this.oneBiddingListA.bidBiddingEnd,
        bidStopStatus: status
      }).then(res => {
        if (res.success == 1) {
          if (status == 'Y') {
            this.$message({
              type: 'success',
              message: '暂停竞价成功'
            })
          } else {
            this.$message({
              type: 'success',
              message: '开始竞价成功'
            })
          }
          this.biddingHome()
        }
      })
    },

    //退出竞价室
    outBidding() {
      ;(this.RefTypeDialogVisible = false), (this.RefTypeData = []), (this.currentCode = []), window.clearInterval(this.timer)
      window.clearInterval(this.refresh)
      this.box = ''
      this.refreshList()
    },

    //刷新竞价室
    biddingHome() {
      querytSignUpSugar({
        bidId: this.RefTypeData.bidId,
        signupStatus: 'Y'
        // sugarId: this.currentCode.sugarId
      }).then(res => {
        if (res.success == 1) {
          this.currentCodeList = res.data
          this.oneSugarList = res.data
          this.oneBiddingListA.rank = res.data[0].rank
          this.RefTypeData.biddingPrice = res.data[0].biddingPrice
        }
      })
      queryBiddingList({
        bidCode: this.queryParam.bidCode,
        biddingStatus: this.queryParam.biddingStatus,
        bidAuditstatus: 'Y',
        bidBiddingstatus: 'Y',
        enrollStatus: 'Y',
        bidId: this.RefTypeData.bidId,
        PageIndexs: this.Pagination.currentPage.toString(),
        PageSizes: this.Pagination.pageSize.toString()
      }).then(response => {
        this.TypeList = response.data
        this.oneBiddingList = response.data
        this.oneBiddingListA = response.data[0]
        this.bidStatus = response.data[0].bidStatus
        this.RefTypeData.bidStopStatus = response.data[0].bidStopStatus
      })
    },

    //手动刷新竞价室
    refreshHome() {
      if (this.box == this.endText) {
        window.clearInterval(this.refresh)
      } else {
        this.refreshRank()
        window.clearInterval(this.refresh)
        this.refresh = setInterval(this.refreshRank, 30000)
      }
    },

    //更新名次
    refreshRank() {
      querytSignUpSugar({
        bidId: this.RefTypeData.bidId,
        signupStatus: 'Y'
      }).then(res => {
        if (res.success == 1) {
          this.currentCodeList = res.data
          var nub = this.oneSugarList.find(n => n.sugarId == '9')
          res.data.forEach(element => {
            var nub = this.oneSugarList.find(n => n.sugarId == element.sugarId)
            element.biddingPrices = nub.biddingPrices
          })
          this.oneSugarList = res.data
          this.oneBiddingListA.rank = res.data[0].rank
          this.RefTypeData.biddingPrice = res.data[0].biddingPrice
          queryNowTime().then(res => {
            if (res.success === '1') {
              this.nowtime = res.data
              let date = new Date(this.nowtime)
              let startime = new Date(Date.parse(this.RefTypeData.bidBiddingStart))
              let endtime = new Date(Date.parse(this.RefTypeData.bidBiddingEnd))
            }
            window.clearInterval(this.timer)
            this.aaaa()
          })
        }
      })
    },

    // 确认竞价
    biddingTrue() {
      // let date =  new Date(this.nowtime)
      // let startime = new Date(Date.parse(this.RefTypeData.bidBiddingStart))
      // let endtime = new Date(Date.parse(this.RefTypeData.bidBiddingEnd))
      // if(date > endtime){
      //   this.$alert('十分抱歉，该竞价已经结束', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      if (this.box == this.endText) {
        this.$alert('十分抱歉，该竞价已经结束', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      var i = 1
      var msg = ''
      var m = 0
      this.oneSugarList.forEach(element => {
        element.bidId = this.RefTypeData.bidId
        var row = Object.assign({}, element)
        if (row.biddingPrices < this.RefTypeData.bidOfferStart || row.biddingPrices > this.RefTypeData.bidOfferEnd) {
          msg = msg + '需求编号为：' + row.demandCode + ',出价要在规定的报价范围内才有效！' + '</br>'
          row.biddingPrices = ''
        }
        if (row.biddingPrice && row.biddingPrices > row.biddingPrice) {
          msg = msg + '需求编号为：' + row.demandCode + ',更新报价只能比当前出价要低！' + '</br>'
          row.biddingPrices = ''
        }
        if(row.biddingPrices == '0' && row.biddingPrices == ''){
          msg = msg + '需求编号为：' + row.demandCode + ',报价不可为0或空！' + '</br>'
        }
        var str = '' + element.biddingPrices
        if (str.indexOf('.') != -1) {
          var price = []
          price = str.split('.')
          if (price[1].length > 2) {
            msg = msg + '需求编号为：' + element.demandCode + ',报价只能由数字和两位小数组成' + '</br>'
          }
        }
        if (element.biddingPrices % 0.5 != 0) {
          msg = msg + '需求编号为：' + element.demandCode + ',报价只能为0.5的倍数' + '</br>'
        }
        if (!element.biddingPrices) {
          m++
        }
        if (m === this.oneSugarList.length) {
          this.$alert('出价不能都为空！', '提示', { dangerouslyUseHTMLString: true })
          return
        }
        if (i === this.oneSugarList.length) {
          if (msg) {
            this.$alert(msg, '提示', { dangerouslyUseHTMLString: true })
            return
          } else {
            var k = 1
            this.oneSugarList.forEach(element => {
              var row = Object.assign({}, element)
              if (row.biddingPrices && row.biddingPrices != row.biddingPrice && row.biddingPrices != this.RefTypeData.bidOfferEnd) {
                haveBiddingPrice({ sugarId: row.sugarId, biddingPrices: row.biddingPrices, bidId: this.RefTypeData.bidId }).then(res => {
                  if (res.msg != '成功！') {
                    msg = msg + '需求编号为：' + row.demandCode + ',该报价已存在' + '</br>'
                    row.biddingPrices = ''
                  }
                  if (k === this.oneSugarList.length) {
                    if (msg) {
                      this.$alert(msg, '提示', { dangerouslyUseHTMLString: true })
                    } else {
                      biddingInfoMethod(this.oneSugarList).then(res => {
                        if (res.success === '1') {
                          this.$message({
                            type: 'success',
                            message: '竞价成功'
                          })
                          this.biddingHome()
                        }
                      })
                    }
                  }
                  k++
                })
              } else if (k === this.oneSugarList.length && !msg) {
                biddingInfoMethod(this.oneSugarList).then(res => {
                  if (res.success === '1') {
                    this.$message({
                      type: 'success',
                      message: '竞价成功'
                    })
                    this.biddingHome()
                  }
                })
              } else {
                k++
              }
            })
          }
        }
        i++
      })
    },

    //查看竞价信息
    queryBiddingButton() {
      queryBiddingInfo({ sugarId: this.currentCode.sugarId }).then(res => {
        if (res.success === '1') {
          this.biddingCodeList = res.data
          this.biddingInfoList = true
        }
      })
    },

    // dialog 查看线路详细信息
    showTransportMethod(val) {
      this.tranDialogInfoList[0] = val
      this.tranDialogInfoDialogVisible = true
    },

    getCurrentTypeRow(row) {
      this.currentPage = 1
      this.pageSize = 30
      this.pageTotal = 0
      this.currentType = row
      this.RefTypeData = Object.assign({}, row)
      // selectBiddingInfo({
      querytSignUpSugar({
        bidId: row.bidId,
        signupStatus: 'Y'
      }).then(res => {
        if (res.success == 1) {
          this.currentCodeList = res.data
        }
      })
    },

    // 获取当前选中行(多行)
    rowSelectionChange(val) {
      this.sugarIds = []
      val.forEach(element => {
        this.sugarIds.push(element.sugarId)
      })
    },

    // 点击基础代码表格的一行，获取到当前行的信息
    getCurrentCodeRow(row) {
      this.currentCode = row
    },
    handleSizeChangeA(val) {
      this.pageSize = val
      this.getRefCode()
    },
    handleCurrentChangeA(val) {
      this.currentPage = val
      this.getRefCode()
    },
    handleTypeDialogClose() {
      this.RefTypeDialogVisible = false
      ;(this.RefTypeData = []), (this.currentCode = []), window.clearInterval(this.refresh)
      window.clearInterval(this.timer)
      this.box = ''
      this.refreshList()
      this.tranDialogInfoDialogVisible = false
    },
    handleCodeDialogClose() {
      this.RefCodeDialogVisible = false
    },
    // restet 基础代码
    resetRefCode() {
      return (this.RefCodeData = {
        // RCT_UUID: '',
        // RV_DOMAIN: '',
        // RV_CMEANING: '',
        // RV_NAME: '',
        // RV_ISVALID: 'Y',
        rvDomain: '',
        rvTerId: '-1',
        rvLowValue: '',
        rvCmeaning: '',
        rvIsvalid: 'Y'
        // rvInsertuser:'',
        // rvLstupduser:'',
      })
    },
    checkStep() {
      this.stepDialog.show = true
    },
    doUpdateStep() {
      this.$refs['stepFromRef'].validate(valid => {
        if (valid) {
          this.priceStep = this.stepDialog.data.step
          this.$message.success('修改成功')
          this.$refs['stepFromRef'].clearValidate()
          this.stepDialog.show = false
        }
      })
    },
    stepDialogOpen() {
      this.stepDialog.data.step = parseFloat(this.priceStep)
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .splitter-pane-resizer.horizontal {
  margin-top: -15px;
}
.titleq {
  width: 100%;
  height: 60px;
  background: #3d85c6;
  margin-bottom: 10px;
  color: #fff;
  font-size: 16px;
  line-height: 60px;
  border-radius: 8px;
  padding-left: 5px;
  position: relative;
  .titleA {
    float: left;
  }
  .righg {
    width: 200px;
    height: 60px;
    line-height: 60px;
    padding-left: 5px;
    background: #fff;
    float: right;
    margin-right: 50px;
    color: #000;
    border: 2px solid #3d85c6;
    border-radius: 8px;
  }
}
.tu {
  width: 50px;
  height: 45px;
  position: absolute;
  right: 267px;
  top: 8px;
  img {
    width: 100%;
    height: 100%;
  }
}
.heis {
  width: 100%;
  height: 65px;
  margin-top: 10px;
  margin-bottom: 10px;
  .biao {
    width: 250px;
    height: 60px;
    border: 2px solid #cccccc;
    line-height: 60px;
    font-size: 16px;
    border-radius: 8px;
    text-align: center;
    float: left;
    span {
      font-size: 18px;
      font-weight: bold;
      margin-top: 5px;
    }
  }
  .sysj {
    width: 422px;
    height: 60px;
    float: left;
    line-height: 60px;
    font-size: 18px;
    margin-left: 170px;
    position: relative;
    img {
      width: 50px;
      height: 50px;
      position: absolute;
      right: 0;
      top: 3px;
      // margin-left: 10px;
    }
  }
  .rigth {
    float: right;
    height: 60px;
    line-height: 60px;
    margin-right: 50px;
    font-size: 16px;
    color: #6d9eeb;
  }
  .left {
    float: left;
    height: 60px;
    line-height: 60px;
    margin-right: 50px;
    font-size: 16px;
    color: #6d9eeb;
  }
}
.pic {
  overflow: auto;
}
.app-container {
  overflow: hidden;
  background-color: #fff;
  position: relative;
  height: 100%;
}
.tree {
  padding-right: 20px;
  font-size: 1.4rem;
}
.right-detail {
  height: 100%;
  .top-type {
    width: 100%;
    height: 100%;
    table {
      max-width: 100%;
      font-size: 1.4rem;
    }
  }
  .bottom-code {
    width: 100%;
    height: 100%;
  }
}
.codeNumberCode {
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 20px;
}
.basicInfoBox {
  border: 1px solid #cccccc;
  border-radius: 5px;
  padding-top: 25px;
  padding-bottom: 10px;
}
.el-upload__tip[data-v-2d30027a] {
  font-size: 12px;
  color: #606266;
  margin-top: 7px;
  width: 260px;
}
</style>
